/*
 * Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
 *
 * Licensed under the Mulan PSL v2.
 * You can use this file according to the terms and conditions of the Mulan PSL v2.
 * You may obtain a copy of the License at
 *
 *     http://license.coscl.org.cn/MulanPSL2
 *
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
 * FOR MORE DETAILS.
 */

#pragma once

#include "highfive/H5File.hpp"

#include "DBManager/IRepository/Input/Property/IPFASTTRepository.h"
#include "DBManager/Repository/HDF5/Base/SingleRepositoryBase.h"

template <>
inline HighFive::DataType HighFive::create_datatype<SG::DataStructure::FEM::PFASTTData> ()
{
    HighFive::CompoundType compoundType = { { "PID", HighFive::create_datatype<SG::DataStructure::Common::Id> () },
                                            { "TKID", HighFive::create_datatype<SG::DataStructure::Common::Id[6]> (), 8, true },
                                            { "TGEID", HighFive::create_datatype<SG::DataStructure::Common::Id> () },
                                            { "TKNID", HighFive::create_datatype<SG::DataStructure::Common::Id[6]> (), 8, true },
                                            { "FDC", HighFive::create_datatype<char[8]> (), 1, true },
                                            { "FUSE", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
                                            { "DIR", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
                                            { "OPTION", HighFive::create_datatype<char[8]> (), 1, true },
                                            { "LOWER", HighFive::create_datatype<SG::DataStructure::Common::Real> () },
                                            { "UPPER", HighFive::create_datatype<SG::DataStructure::Common::Real> () },
                                            { "FRATE", HighFive::create_datatype<SG::DataStructure::Common::Real> () },
                                            { "LRGR", HighFive::create_datatype<SG::DataStructure::Common::I64> () },
                                            { "DOMAIN_ID", HighFive::create_datatype<SG::DataStructure::Common::Id> () } };
    return compoundType;
}

SG_DBMANAGER_HDF5_NAMESPACE_OPEN

class DBManager_DECLSPEC PFASTTRepository : public IPFASTTRepository, public SingleRepositoryBase<SG::DataStructure::FEM::PFASTTData>
{
  public:
    explicit PFASTTRepository (HDF5Database& database);

    void InitialDatasetInfo () override;
};

SG_DBMANAGER_HDF5_NAMESPACE_CLOSE
